home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0793 / RIPICONS.PAS < prev    next >
Pascal/Delphi Source File  |  1993-08-01  |  2KB  |  55 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 342 of 353
  3. From : John Linden                         1:280/17.0           23 Jul 93  22:09
  4. To   : Martin Bouchard
  5. Subj : BGI
  6. ────────────────────────────────────────────────────────────────────────────────
  7. MB> I need to convert some file that are in Borland BGI format. Those files are
  8. MB> simple icons in 16 colors. My experience tell me that this file format is
  9. MB> based on bitplanes, but it's only a guess. Could anybody help?
  10. MB>
  11. MB> BTW, this is the same format used byicons in RIPTERM.
  12.  
  13. Hmm, well since I am writing an RIP icon editor, I can probably help. The
  14. icons are saved using the GetImage and PutImage. The following routines are
  15. some that I use to load and save icons.}
  16.  
  17. USES graph;
  18.  
  19. Type  BigArray     =Array[1..60000] of Byte;
  20.       PBigArray    =^BigArray;
  21.  
  22.  
  23. Var   F            :File;
  24.       IconSize     :Word;
  25.       Icon         :PBigArray;
  26.       Gd,Gm        :Integer;
  27.  
  28. Procedure LoadIcon(FN:String);
  29. Begin
  30.   Assign(F,FN);
  31.   {$I-} Reset(F,1); {$I+}
  32.   IconSize:=FileSize(F); 
  33.   GetMem(Icon, IconSize); 
  34.   BlockRead(F,Icon^,IconSize);
  35.   PutImage(1,1,Icon^,CopyPut);
  36.   Close(F);
  37. End;
  38.  
  39. Procedure SaveIcon( X1, Y1, X2, Y2: Integer;
  40.                      FileName: String);
  41. Var
  42.    FileToSave   : File;
  43.    I            : Integer;
  44.    PointImage   : Pointer;
  45.    Size         : Word;
  46. Begin
  47.      Assign(FileToSave, FileName);
  48.      Size := ImageSize(X1, Y1, X2, Y2);
  49.      ReWrite(FileToSave, Size);
  50.      GetMem(PointImage, Size);
  51.      GetImage(X1, Y1, X2, Y2, PointImage^);
  52.      BlockWrite(FileToSave, PointImage^, 1);
  53.      FreeMem(PointImage, Size);
  54.      Close(FileToSave);
  55. End;